package com.bdzl.pub.util.param;

import java.util.HashMap;
import java.util.Map;

public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	public static final String 处理成功="0000";
	public static final String 处理失败="0001";
	public static final String 程序异常="0002";
	public static final String 网络超时="0003";
	public static final String 参数异常="0004";
	public static final String 请求过于频繁="0005";
	public static final String IP地址非法="0006";
	public static final String 无权限="0007";
	public static final String 验证码错误="0008";
	public static final String 用户名或密码错="0009";
	public static final String 用户状态异常="0010";
	public static final String 数据为空="0011"; //处理成功并且数据为空
	public static final String 登录失效="0012";//登录失效，或登录过期，或已经被注销等


	public R() {
		put("respCode", R.处理成功);
		put("respMsg", "操作成功");
	}

	public static R error() {
		return error(R.处理失败, "操作失败");
	}

	public static R error(String msg) {
		return error(R.程序异常, msg);
	}

	public static R error(String code, String msg) {
		R r = new R();
		r.put("respCode", code);
		r.put("respMsg", msg);
		return r;
	}

	public static R ok(String msg, Object data) {
		R r = new R();
		r.put("respMsg", msg);
		r.put("data", data);
		return r;
	}

	public static R ok(Map map) {
		R r = new R();
		r.putAll(map);
		return r;
	}

	public static R ok(Object data){
		R r = new R();
		r.put("data",data);
		return R.ok("操作成功",data);
	}

	public static R ok() {
		return new R();
	}

	public static R add(String key,Object value){
		R r = R.ok();
		r.put(key,value);
		return r;
	}
}
